import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SRobIslandFightingInfo } from "../../../../../Message/Game/SRobIslandFightingInfo";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { PetIslandUtil } from "../PetIslandUtil";
import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { SecTimerView } from "../../common/SecTimerView";
import { FilterConst } from "../../../../component/gconst/FilterConst";
//class PetIslandBroadcastItemRenderer
    
    export  class PetIslandBroadcastItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */onLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandMapShowByPosition, this._vo.pos));
            return;
        }

        /* internal  */onSecViewTimeChange(arg1: DataEvent): void
        {
            var loc1=int(arg1.data);
            if (loc1 <= 0) 
            {
                this._tfLeftTime.stop();
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            if (typeof arg1 === "srobislandfightinginfo") 
            {
                this._vo = arg1 as SRobIslandFightingInfo;
                loc1 = GameDefConfig.instance.getPetIslandName(this._vo.pos.isLand);
                if (PetIslandUtil.isInGuild(this._vo.attackGuildId)) 
                {
                    this._tfLeftTime.setParse(Language.getStringByParam(28198, HTMLUtil.addColor(this._vo.defenseGuildName, GlobalStyle.color6), PetIslandUtil.getPosName(this._vo.pos, true, false), "＞＞"));
                }
                else 
                {
                    this._tfLeftTime.setParse(Language.getStringByParam(28197, this._vo.attackGuildName, PetIslandUtil.getPosName(this._vo.pos, true, false), "＞＞"));
                }
                this._tfLeftTime.setLeftTime(this._vo.startSeconds);
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            ObjCreate.createGButton("", 1, 1, 18, 17, this, "SpeakerButton");
            this._tfLeftTime = new SecTimerView();
            this._tfLeftTime.wordWrap = true;
            this._tfLeftTime.multiline = true;
            this._tfLeftTime.selectable = false;
            this._tfLeftTime.defaultTextFormat = GlobalStyle.setTextFormatLeading(GlobalStyle.textFormat1, 5);
            this._tfLeftTime.filters = [FilterConst.glowFilter];
            this._tfLeftTime.addEventListener(EventName.SecViewTimeChange, this.onSecViewTimeChange);
            this._tfLeftTime.addEventListener(flash.events.TextEvent.LINK, this.onLinkHandler);
            ObjCreate.setObjAttri(this._tfLeftTime, 0, 0, 196, 60, this);
            return;
        }

        /* internal */ /* var */_tfLeftTime: SecTimerView;

        /* internal */ /* var */_vo: SRobIslandFightingInfo;
    }
